﻿@model Kooboo.CMS.Common.KeyValue<string, string>
@{
    Layout = ViewBag.Layout ?? "_TR.cshtml";
    ViewData.TemplateInfo.HtmlFieldPrefix = ViewData.TemplateInfo.HtmlFieldPrefix.Replace(ViewData.ModelMetadata.PropertyName, "").Trim('.');
    var propertyName = ViewData["name"] == null ? ViewData.ModelMetadata.PropertyName : ViewData["name"].ToString();
    var defaultValue = ViewData.ModelMetadata.AdditionalValues.ContainsKey("DefaultValue") ? ViewData.ModelMetadata.AdditionalValues["DefaultValue"] : 0;
    var editorHtmlAttributes = Html.GetUnobtrusiveValidationAttributes(propertyName, ViewData.ModelMetadata);

    var htmlAttributes = ViewBag.HtmlAttributes;
    if (htmlAttributes != null)
    {
        if (htmlAttributes is IDictionary<string, object>)
        {
            editorHtmlAttributes.Merge((IDictionary<string, object>)htmlAttributes);
        }
        else
        {
            editorHtmlAttributes.Merge(new RouteValueDictionary(htmlAttributes));
        }
    }
    editorHtmlAttributes = editorHtmlAttributes.Merge("class", ViewData["class"]).Merge("autocomplete", ViewData["autocomplete"] ?? "on").Merge("value-type", "int32");
}
<table class="key-value">
    <tr class="field">
        <td>
            <input type="text" id="@(propertyName + "_Key")" name="@(propertyName + ".Key")" class="medium" value="@(Model == null ? "" : Model.Key)" placeholder="Key" /></td>
    </tr>
    <tr class="field">
        <td>
            <input type="text" id="@(propertyName + "_Value")" name="@(propertyName + ".Value")" class="medium" value="@(Model == null ? "" : Model.Value)" placeholder="Value" /></td>
    </tr>
</table>
@if (!string.IsNullOrEmpty(ViewData.ModelMetadata.Description))
{
    <em class="tip">@Html.Raw(ViewData.ModelMetadata.Description.Localize())</em>
}